package work;

public class Test1Multithreading {
    public static void main(String[] args) {
        Runnable printGreet = new PrintGreet("hello",50);
        Runnable printInFo = new PrintInFo(2001,"龙包");
        Runnable printBye = new PrintBye("再见",50);

        // Create threads
        Thread thread1 = new Thread(printGreet);
        Thread thread2 = new Thread(printInFo);
        Thread thread3 = new Thread(printBye);

        // Start threads
        thread1.start();
        thread2.start();
        thread3.start();

    }

}
class PrintGreet implements Runnable {
    private String Greet;   //问候语句
    private int time; //打印次数

    public PrintGreet(){}
    public PrintGreet(String Greet,int t){
        this.Greet = Greet;
        time = t;
    }

    @Override
    public void run() {
        for (int i = 0; i < time; i++) {
            System.out.print(Greet+" ");
        }
    }
}

class PrintInFo implements Runnable{
    //学生信息
    private int id;
    private String name;


    public PrintInFo(){}
    public PrintInFo(int id,String name){
        this.id = id;
        this.name = name;
    }

    @Override
    public void run() {
        System.out.println("学生姓名:"+name);
        System.out.println("学生ID:"+id);
    }
}

class PrintBye implements Runnable{
    private String bye;
    private int time;
    public PrintBye(){}
    public PrintBye(String bye,int time){
        this.bye = bye;
        this.time = time;
    }

    @Override
    public void run() {
        for (int i = 0; i < time; i++) {
            System.out.print(bye+" ");
        }
    }
}